<!--
1. checkbox是复选框
2. 如果不添加key的话，那么就会出现bug
-->

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../lib/vue.js"></script>

</head>
<body>
    <div id="app">

        <div>
            <label>
                Id:<input type="text" v-model="id">
            </label>
            <label>
                Name:<input type="text" v-model="name">
            </label>
            <input type="button" value="添加" @click="add">
        </div>

        <p v-for="item in objList" :key="item">
            <input type="checkbox">
            {{item.id}}:{{item.name}}
        </p>
    </div>
    <script>
        var vm=new Vue({
            el:"#app",
            data:{
                id:'',
                name:'',
                objList:[
                    {id:1,name:'zmj1'},
                    {id:2,name:'zmj2'},
                    {id:3,name:'zmj3'},
                    {id:4,name:'zmj4'}
                ],
            },
            methods:{
                add(){
                    // this.objList.push({id:this.id,name:this.name});
                    this.objList.unshift({id:this.id,name:this.name});
                }
            }
        })
    </script>
</body>
</html>